<?php
namespace Index\Controller;
use Think\Controller;
// use Index\Controller\CommonController;
class SearchController extends Controller {
    public function indexAction(){

        $wd = I('get.q');

        $num = 5;

        import("Vendor.Pscws.pscws4");

        $pscws = new \PSCWS4();

        $pscws->PSCWS4('utf8');

        $pscws->set_dict(CONF_PATH . 'etc/dict.utf8.xdb');

        $pscws->set_rule(CONF_PATH . 'etc/rules.utf8.ini');

        $pscws->set_ignore(true);

        $pscws->send_text($wd);

        $words = $pscws->get_tops($num);

        $pscws->close();


        $sql = "select * from question where ";

        foreach ($words as $val) {
            $sql .= " title like "."'%".$val['word']."%' or";
        }

        $sql = substr($sql,0,-2);


        $modle = M();

        $resData = $modle->query($sql);


         return implode(',', $tags);

        $this->assign('resData',$resData);

        $this->display('index');
    }
}